﻿using System.Diagnostics;

namespace Searcher
{
    public class FileItem
    {
        public string file { get; set; }

        public string fileName => Path.GetFileName(file);

        public OpenType type { get; set; }

        public FileItem(string file, OpenType type)
        {
            this.file = file;
            this.type = type;
        }


        public void Open()
        {
            switch (type)
            {
                case OpenType.打开文件:
                    Process.Start("explorer", $"{file}");
                    break;

                case OpenType.打开目录:
                    Process.Start("explorer", $"/select,{file}");
                    break;
            }
        }


        public override string ToString()
        {
            switch (type)
            {
                case OpenType.打开文件:
                    return $"打开[{fileName}]";

                case OpenType.打开目录:
                    return $"打开[{fileName}]目录";

                default:
                    throw new Exception();
            }
        }

        public enum OpenType { 打开文件, 打开目录 }


    }
}